
<!DOCTYPE html>
<html lang="">


<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
  <meta name="theme-color" content="#202020">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>
  
  
    <meta name="keywords" content="hexo,">
  

  
    <meta name="description" content="5分钟搞定个人博客">
  
  
  <link rel="icon" type="image/x-icon" href="/logo.png">
  <title>5分钟搞定个人博客 [ 复制粘贴工程师 ]</title>
  
    <!-- stylesheets list from config.yml -->
    
      <link rel="stylesheet" href="//cdn.bootcss.com/pure/1.0.0/pure-min.css">
    
      <link rel="stylesheet" href="/css/xoxo.css">
    
  
</head>


<body>
  <div class="nav-container">
    <nav class="home-menu pure-menu pure-menu-horizontal">
  <a class="pure-menu-heading" href="/">
    <img class="avatar" src="https://wx.qlogo.cn/mmopen/vi_32/AMpRacDgkTPogKk4gQ5IC3QezP55XoPpicQpnD9Vz3eNz6OPFYyFrFzCa4EGQGH65kPia5YJwQBBvvJpVwQ4lfVg/132">
    <span class="title">复制粘贴工程师</span>
  </a>

  <ul class="pure-menu-list clearfix">
      
          
            <li class="pure-menu-item"><a href="/" class="pure-menu-link">首页</a></li>
          
      
          
            <li class="pure-menu-item"><a href="/search" class="pure-menu-link">搜索</a></li>
          
      
  </ul>

</nav>
  </div>

  <div class="container" id="content-outer">
    <div class="inner" id="content-inner">
      <div class="post-container">
  <article class="post" id="post">
    <header class="post-header text-center">
      <h1 class="title">
        5分钟搞定个人博客
      </h1>
      <span>
        
        <time class="time" datetime="2019-02-19T07:45:48.000Z">
        2019-02-19
      </time>
        
      </span>
      <span class="slash">/</span>
      <span class="post-meta">
      <span class="post-tags">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/">hexo</a></li></ul>
      </span>
    </span>
      <span class="slash">/</span>
      <span class="read">
      <span id="busuanzi_value_page_pv"></span> 点击
    </span>
      <span class="slash">/</span>
    </header>

    <div class="post-content">
      <p>民间有传言，没有手撸过个人网站的程序员不是一个好的前端开发工程师，可是！强撸灰飞湮灭！为了自己的身体健康，还是少撸为妙！不要998，也不要98，完全免费，<a href="https://hexo.io/zh-cn/" target="_blank" rel="noopener">hexo</a>你直接带回家。通过hexo，可以快速构建个人博客，并搭建到 <code>github</code> 上供他人访问，三秒真男人，我们开始吧！</p>
<a id="more"></a>
<h3 id="1-新建仓库"><a href="#1-新建仓库" class="headerlink" title="1. 新建仓库"></a>1. 新建仓库</h3><p>都说了要给他人访问，如果你连个仓库都没有，是不是说不过去？出门右转上 <code>github</code> 新建一个仓库，仓库名必须为 <code>&lt;user-name&gt;.github.io</code> 格式，其中 <code>&lt;user-name&gt;</code> 是你 <code>github</code> 的昵称。不要问我为什么，问我我也不想回答你。</p>
<h3 id="2-全局安装hexo"><a href="#2-全局安装hexo" class="headerlink" title="2. 全局安装hexo"></a>2. 全局安装hexo</h3><p>如果你连 <code>npm</code> 是啥都不知道，对不起，我们的缘分尽了，你走吧。…别，别，别，开个玩笑，有啥问题可以留言。打开命令行，输入下面的命令，全局安装 <code>hexo</code>。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo</span><br></pre></td></tr></table></figure></p>
<h3 id="3-初始化项目"><a href="#3-初始化项目" class="headerlink" title="3. 初始化项目"></a>3. 初始化项目</h3><p><code>Just one</code> 命令，<code>hexo init</code>，就会自动构建一个 <code>hexo</code> 项目，紧接着执行 <code>hexo s</code>，浏览器访问 <code>localhost:4000</code> 就可以看到效果啦！过程一定要快，凉了就不好吃了！<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br><span class="line"></span><br><span class="line"><span class="comment">// 本地运行</span></span><br><span class="line">hexo s</span><br></pre></td></tr></table></figure></p>
<h3 id="4-部署到github"><a href="#4-部署到github" class="headerlink" title="4. 部署到github"></a>4. 部署到github</h3><p>虽然只有一份 <code>Hello World</code>，但是我也想让全世界的人看到，成为最闪耀的那个崽，可咋整？不要慌，快速在项目根目录下找到 <code>_congif.yml</code>，找到 <code>deploy</code> 字段并填写完整，下面请开始你上学时最擅长的事情：抄写！<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Deployment</span></span><br><span class="line"><span class="comment">## Docs: https://hexo.io/docs/deployment.html</span></span><br><span class="line">deploy:</span><br><span class="line">  <span class="built_in">type</span>: git</span><br><span class="line">  repo: &lt;你的仓库地址&gt; <span class="comment"># https://github.com/TJ-XiaJiaHao/TJ-XiaJiaHao.github.io</span></span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure></p>
<p>抄写完毕！但是！我们需要额外的一个工具来帮助我们推到仓库上，那就是！那就是！那就是 <code>hexo-deployer-git</code>。搞它！<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure></p>
<p>万事俱备，只欠东南风！执行下面两个命令，就可以把项目自动部署到 <code>github</code> 上啦啦啦啦啦。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br><span class="line"></span><br><span class="line">hexo deploy</span><br></pre></td></tr></table></figure></p>
<h3 id="5-查看效果"><a href="#5-查看效果" class="headerlink" title="5. 查看效果"></a>5. 查看效果</h3><p>凡是连环杀手都喜欢在杀人后留在现场，因为他喜欢欣赏自己的杰作！<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">浏览器访问：https://tj-xiajiahao.github.io/ 即可看到效果。</span><br></pre></td></tr></table></figure></p>
<p>至此，已经完成了个人博客的搭建，也可以在浏览器中访问，下面将介绍一些常用的野外生存技能。</p>
<h3 id="如何创建新文章"><a href="#如何创建新文章" class="headerlink" title="如何创建新文章"></a>如何创建新文章</h3><p>阳光明媚，一杯温暖的咖啡，一束倾斜的阳光，惬意地抿一口咖啡，我要开始写博客了！</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// [layout] 为布局，可选项为 `post`、`page`、`draft`，这将决定文章所在文件路径。</span></span><br><span class="line"><span class="comment">// &lt;title&gt; 为文章标题</span></span><br><span class="line"><span class="comment">// 如 hexo new post 除了帅气，我还有啥！</span></span><br><span class="line">hexo <span class="keyword">new</span> [layout] &lt;title&gt;</span><br></pre></td></tr></table></figure>
<h3 id="更换主题皮肤"><a href="#更换主题皮肤" class="headerlink" title="更换主题皮肤"></a>更换主题皮肤</h3><p>风格不喜欢？换之。</p>
<p>更换主题流程：下载主题 -&gt; 配置主题，以 <code>xoxo</code> 为例（不要想歪了！）</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 下载到themes文件夹下</span></span><br><span class="line">git <span class="built_in">clone</span> https://github.com/KevinOfNeu/hexo-theme-xoxo xoxo</span><br><span class="line"></span><br><span class="line"><span class="comment"># 修改 _config.yml 配置</span></span><br><span class="line">theme: xoxo</span><br></pre></td></tr></table></figure>
<h3 id="部署优化"><a href="#部署优化" class="headerlink" title="部署优化"></a>部署优化</h3><p>每次都要执行 <code>hexo clean</code> 和 <code>hexo deploy</code>，不如写个新的脚本</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// package.json</span></span><br><span class="line"><span class="string">"dev"</span>: <span class="string">"hexo s"</span>,</span><br><span class="line"><span class="string">"build"</span>: <span class="string">"hexo clean &amp; hexo deploy"</span></span><br></pre></td></tr></table></figure>
<p>部署命令</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm run build</span><br></pre></td></tr></table></figure>
    </div>

    <div>全文完。</div>
  </article>
  <div class="toc-container">
    
  <div id="toc" class="toc-article">
    <strong class="toc-title">目录</strong>
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-新建仓库"><span class="toc-text">1. 新建仓库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-全局安装hexo"><span class="toc-text">2. 全局安装hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-初始化项目"><span class="toc-text">3. 初始化项目</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-部署到github"><span class="toc-text">4. 部署到github</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-查看效果"><span class="toc-text">5. 查看效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#如何创建新文章"><span class="toc-text">如何创建新文章</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#更换主题皮肤"><span class="toc-text">更换主题皮肤</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#部署优化"><span class="toc-text">部署优化</span></a></li></ol>
  </div>


  </div>
</div>
<div class="copyright">
    <span>本作品采用</span>
    <a href="https://creativecommons.org/licenses/by/4.0/">知识共享署名 4.0 国际许可协议</a>
    <span>进行许可。 转载时请注明原文链接。</span>
</div>
<div class="share" style="width: 100%;">
  <!-- <img src="https://kevinofneu-blog-static.oss-cn-beijing.aliyuncs.com/static/2018-12-10-qrcode_for_gh_ffacf5722095_258.jpg" alt="Running Geek" style="margin: auto; display: block;"/>

  <div style="margin: auto; text-align: center; font-size: 0.8em; color: grey;">老铁们关注走一走，不迷路</div> -->

</div>

  
    <div class="post-nav">
      <div class="post-nav-item post-nav-next">
        
      </div>
  
      <div class="post-nav-item post-nav-prev">
          
          <a href="/2019/02/20/Javascript内存结构分析/" rel="prev" title="Javascript内存结构分析">
            Javascript内存结构分析
          </a>
          <span>〉</span>
        
      </div>
    </div>
  


    </div>

    
    <div id="vcomments" style="max-width: 800px; margin: 16px auto;"></div>
  </div>
  <footer class="footer text-center">
    <div id="bottom-inner">
        <a class="bottom-item" href="/">首页</a> |
        <a class="bottom-item" href="https://github.com/TJ-XiaJiaHao" target="_blank">GitHub</a> |
        <a class="bottom-item">联系邮箱：1452806@tongji.edu.cn</a>
    </div>
</footer>
  

<script>
  (function(window, document, undefined) {

    var timer = null;

    function returnTop() {
      cancelAnimationFrame(timer);
      timer = requestAnimationFrame(function fn() {
        var oTop = document.body.scrollTop || document.documentElement.scrollTop;
        if (oTop > 0) {
          document.body.scrollTop = document.documentElement.scrollTop = oTop - 50;
          timer = requestAnimationFrame(fn);
        } else {
          cancelAnimationFrame(timer);
        }
      });
    }

    var hearts = [];
    window.requestAnimationFrame = (function() {
      return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function(callback) {
          setTimeout(callback, 1000 / 60);
        }
    })();
    init();

    function init() {
      css(".heart{z-index:9999;width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
      attachEvent();
      gameloop();
      addMenuEvent();
    }

    function gameloop() {
      for (var i = 0; i < hearts.length; i++) {
        if (hearts[i].alpha <= 0) {
          document.body.removeChild(hearts[i].el);
          hearts.splice(i, 1);
          continue;
        }
        hearts[i].y--;
        hearts[i].scale += 0.004;
        hearts[i].alpha -= 0.013;
        hearts[i].el.style.cssText = "left:" + hearts[i].x + "px;top:" + hearts[i].y + "px;opacity:" + hearts[i].alpha + ";transform:scale(" + hearts[i].scale + "," + hearts[i].scale + ") rotate(45deg);background:" + hearts[i].color;
      }
      requestAnimationFrame(gameloop);
    }

    /**
     * 给logo设置点击事件
     * 
     * - 回到顶部
     * - 出现爱心
     */
    function attachEvent() {
      var old = typeof window.onclick === "function" && window.onclick;
      var logo = document.getElementById("logo");
      if (logo) {
        logo.onclick = function(event) {
          returnTop();
          old && old();
          createHeart(event);
        }
      }
      
    }

    function createHeart(event) {
      var d = document.createElement("div");
      d.className = "heart";
      hearts.push({
        el: d,
        x: event.clientX - 5,
        y: event.clientY - 5,
        scale: 1,
        alpha: 1,
        color: randomColor()
      });
      document.body.appendChild(d);
    }

    function css(css) {
      var style = document.createElement("style");
      style.type = "text/css";
      try {
        style.appendChild(document.createTextNode(css));
      } catch (ex) {
        style.styleSheet.cssText = css;
      }
      document.getElementsByTagName('head')[0].appendChild(style);
    }

    function randomColor() {
      // return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + ")";
      return "#F44336";
    }

    function addMenuEvent() {
      var menu = document.getElementById('menu-main-post');
      if (menu) {
        var toc = document.getElementById('toc');
        if (toc) {
          menu.onclick = function() {
            if (toc) {
              if (toc.style.display == 'block') {
                toc.style.display = 'none';
              } else {
                toc.style.display = 'block';
              }
            }
          };
        } else {
          menu.style.display = 'none';
        }
      }
    }

  })(window, document);
</script>

  



</body>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<script type="text/javascript">
  new Valine({
    el: '#vcomments',
    appId: '8CwYqXS8IoFbvaA9PmgqGjTf-gzGzoHsz',
    appKey: 'z5bVoSPDPhd8hzlXvDey5Hpz',
    verify:false,
    placeholder: '评论留言'
  })
</script>
</html>
